namespace Permissions.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Data : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Department",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        DepName = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Employee_Role",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Employee_Id = c.Int(),
                        Role_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Employee", t => t.Employee_Id)
                .ForeignKey("dbo.Role", t => t.Role_Id)
                .Index(t => t.Employee_Id)
                .Index(t => t.Role_Id);
            
            CreateTable(
                "dbo.Employee",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Department_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Department", t => t.Department_Id)
                .Index(t => t.Department_Id);
            
            CreateTable(
                "dbo.Role",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Permissionss",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        ResourceName = c.String(),
                        Address = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Role_Permissions",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Permissionss_Id = c.Int(),
                        Role_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Permissionss", t => t.Permissionss_Id)
                .ForeignKey("dbo.Role", t => t.Role_Id)
                .Index(t => t.Permissionss_Id)
                .Index(t => t.Role_Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Role_Permissions", "Role_Id", "dbo.Role");
            DropForeignKey("dbo.Role_Permissions", "Permissionss_Id", "dbo.Permissionss");
            DropForeignKey("dbo.Employee_Role", "Role_Id", "dbo.Role");
            DropForeignKey("dbo.Employee_Role", "Employee_Id", "dbo.Employee");
            DropForeignKey("dbo.Employee", "Department_Id", "dbo.Department");
            DropIndex("dbo.Role_Permissions", new[] { "Role_Id" });
            DropIndex("dbo.Role_Permissions", new[] { "Permissionss_Id" });
            DropIndex("dbo.Employee", new[] { "Department_Id" });
            DropIndex("dbo.Employee_Role", new[] { "Role_Id" });
            DropIndex("dbo.Employee_Role", new[] { "Employee_Id" });
            DropTable("dbo.Role_Permissions");
            DropTable("dbo.Permissionss");
            DropTable("dbo.Role");
            DropTable("dbo.Employee");
            DropTable("dbo.Employee_Role");
            DropTable("dbo.Department");
        }
    }
}
